<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/base.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/style.css">
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script>
		<title>订单管理-需求池</title>
	</head>
	<body>
		<div class="page">
			<div class="main_menu fl">
				<c:forEach items="${sessionScope.MENU_LIST}" var="mainMenu">
					<c:if test="${mainMenu.wOOpid == 20}">
						<div class="menu_name">
							<a href="${pageContext.request.contextPath}/${mainMenu.wOAction}"
								target="main"> <img
								src="${pageContext.request.contextPath}${mainMenu.wOIcon}">
								<p>${mainMenu.wOName}</p>
							</a>
						</div>
					</c:if>
				</c:forEach>
			</div>
			
				<div class="main_cont fl">
					<div class="main_cont_top">
						<div class="main_inner clearfix">
							
							<div class="cont_top_time fr"> <i><img src="${pageContext.request.contextPath}/images/images/refresh.png">
							<a href="${pageContext.request.contextPath}/need/waitNeedList/1.html">刷新</a>
							</i></div>
						</div>
					</div>
					<div class="main_cont_top">
						<div class="main_inner clearfix">
							
							<div class="cont_top_time fr">
								<select id="status">  
									<option value ="0">全部订单</option>
									<option value ="1">未接受</option>
									<option value ="2">已接受</option>
									<option value ="3">完成</option>
									<option value ="4">取消</option>
								</select>
								<select id="supplier">  
									<option value ="0" >全部渠道商</option>
									 <c:forEach items="${SUPPLIER_LIST}" var="supplier">
										<option value="${supplier.id}">${supplier.wSName}</option>
									 </c:forEach>
								</select>
								<input type="button" value="需求搜索" onclick="ref()" class="search">
							</div>
						</div>
					</div>
					<div class="main_cont_bottom_xqc">
						<div class="main_inner">
							<table>
							    <thead>
							    <tr> 
							        <th style="width:5%">需求编号</th> 
							        <th style="width:10%">需求工种</th>
							        <th style="width:5%">需求价格</th> 
							        <th style="width:15%">服务地址</th>
							        <th style="width:15%">需求提交时间</th> 
							        <th style="width:10%">状态</th>
							        <th style="width:20%">操作</th>
							    </tr>
							    </thead>  
							    <tbody>
							    <c:forEach items="${PAGE_BEAN.dataList}" var="need">
									<tr class="text-c">
										<td><c:out value="${need.id}"/></td>
										<td> 
										<c:if test="${need.wNeedType eq 9}">
											月嫂
										</c:if>
										<c:if test="${need.wNeedType eq 7}">
											医院护工
										</c:if>
										<c:if test="${need.wNeedType eq 8}">
											育婴师
										</c:if>
										<c:if test="${need.wNeedType eq 6}">
											保姆
										</c:if>
										<c:if test="${need.wNeedType eq 10}">
											看护老人
										</c:if>
									</td>
										<td><c:out value="${need.wFeeType}"/></td>
										<td><c:out value="${need.wAddress}"/></td>
										<td><fmt:formatDate value="${need.createTime}" type="BOTH" dateStyle="full"/></td>
										<td>
										<c:if test="${need.status eq 1}">
											待处理
										</c:if>
										<c:if test="${need.status eq 2}">
											已抢单
										</c:if>
										<c:if test="${need.status eq 3}">
											完成
										</c:if>
										<c:if test="${need.status eq 4}">
											取消
										</c:if>
										</td>
										<td class="td-manage">
											<button type="button"  onclick="detail(${need.id});" >查看详情</button>
													
										</td>
									</tr>
								</c:forEach>
								</tbody> 
							</table>
							<%@ include file="/WEB-INF/views/page.jsp"%>
							<input type="hidden" id="sMoney" value="${suMoney}"/>
						</div>
					</div>
				</div>
			</div>
			<div class="mask_ddxq">
				<div class="ckddxq">
					<img src="${pageContext.request.contextPath}/images/images/close.png" class="close" onclick="qxddxq();">
					<h3>需求详情</h3>
					<ul id="detail">
					</ul>
				</div>
			</div>
			
			
		</div>
		
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/layer/2.1/layer.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/laypage/1.2/laypage.js"></script> 
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/My97DatePicker/WdatePicker.js"></script> 
		<script type="text/javascript" src="${pageContext.request.contextPath}/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
				<script type="text/javascript">
				$(function(){
					$('.table-sort').dataTable({
						"bLengthChange": false, //改变每页显示数据数量
						"aaSorting": [[ 1, "desc" ]],//默认第几个排序
						"bStateSave": true,//状态保存
						"bPaginate" : false,// 分页按钮  
						"aoColumnDefs": [
						  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
						  {"orderable":false,"aTargets":[0,3,3]}// 制定列不参与排序
						]
					});								
				});
				
				
				function detail(id){
					  $.ajax({
						  url: "${pageContext.request.contextPath}/need/findNeedById/"+id+".json",
						  success:function(data) {
								  var list=data.list;
								 
								  $("#detail").html("");
								  $("#detail").append("<li>用户编号："+list[0].wMemberId+"</li>");
								  $("#detail").append("<li>用户名字："+list[0].wContact+"</li>"); 
								  $("#detail").append("<li>用户电话："+list[0].wMemberMobile+"</li>");
								  $("#detail").append("<li>需求价格："+list[0].wFeeType+"</li>");
								 
								  $("#detail").append(data.info);
								  $("#detail").append("<input type=\"button\" onclick=\"move(" + list[0].id + ")\" value=\"重新分配\"/>");
								  $(".mask_ddxq").show(); 
						  }
					});   
				}
				
				function qxddxq(){
					$(".mask_ddxq").hide();
				}
				function move(id) {
					var supplierId = document.getElementById('supplierId').value;
					
					$.ajax({
						  url: "${pageContext.request.contextPath}/mNeed/move/"+id+"/" + supplierId + ".json",
						  success:function(data) {
							  alert(data.info);
						  }
						  });
				}
				function ref() {
					var status = document.getElementById('status').value;
					var supplierId = document.getElementById('supplier').value;
				
					window.location.href='${pageContext.request.contextPath}/mNeed/list/'+ supplierId +'/'+ status +'/1.html';
				}
				</script>
	</body>
</html>
